package Controller.CustomerCompany;
import Service.CustomerCompanyService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Map;

@WebServlet(name = "selectAllCustomerCompany", value = "/selectAllCustomerCompany")
public class SelectAllCustomerCompany extends HttpServlet {
    private CustomerCompanyService customerCompanyService = new CustomerCompanyService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String name = request.getParameter("name");
        String work = request.getParameter("work");
        try {
            Map<String,Object> map = customerCompanyService.selectAllCustomerCompany(name,work);
            request.setAttribute("map",map);
            System.out.println(map);
            request.getRequestDispatcher("/ListCustomerCompany.jsp").forward(request,response);
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}